﻿/*
Initialization after adding Season functionality
USER: wolborski
DATE: 08/20/2012us
*/

if not exists (select 1 from Seasons where Id = 1)
begin

	INSERT INTO [dbo].[Seasons]
           ([ID]
           ,[Name]
           ,[BeginDate]
           ,[EndDate]
           ,[InsertUser]
           ,[InsertDate]           
           ,[Deleted])
     VALUES
           (1
           ,'2014 May'
           ,'2014-05-15'
           ,'2014-06-07'
           ,'wolborski'
           ,getdate()           
           ,0)

	update GameTeams
	set SeasonId = 1

	update Games
	set SeasonId = 1

	alter table GameTeams alter column SeasonId int not null;
	
	alter table Games alter column SeasonId int not null;

end

if not exists (select 1 from Seasons where Id = 2)
begin

	INSERT INTO [dbo].[Seasons]
           ([ID]
           ,[Name]
           ,[BeginDate]
           ,[EndDate]
           ,[InsertUser]
           ,[InsertDate]           
           ,[Deleted])
     VALUES
           (2
           ,'2014 Jun'
           ,'2014-06-08'
           ,'2014-07-19'
           ,'wolborski'
           ,getdate()           
           ,0)	

end
go
